﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;

/// <summary>
/// Summary description for DBTypeMapping
/// </summary>
public static class DBTypeMapping
{
    private static DbType cString;

    private enum ECTypes { String, Int32 }
    private enum EDbTypes { String, Int32 }

    public static DbType GetDbType(Type cType)
    {
        ECTypes eCType = (ECTypes)Enum.Parse(typeof(ECTypes), cType.Name, true);
        switch (eCType)
        {
            case ECTypes.Int32:
                return DbType.Int32;
            case ECTypes.String:
                return DbType.String;
            default:
                 throw new FormatException();                
        }        
    }

    public static Type GetCType(DbType dbType)
    {
        EDbTypes eDbType = (EDbTypes)Enum.Parse(typeof(EDbTypes), dbType.ToString(), true);
        switch (eDbType)
        {
            case EDbTypes.Int32:
                return typeof(int);
            case EDbTypes.String:
                return typeof(String);
            default:
                throw new Exception();
        }
    }
}
